/*
 * nwpu/2011/2011_2.c
 *
 * Harry Wei <harryxiyou@gmail.com> (C) 2013
 */
#include <stdio.h>
#include <stdlib.h>

#define DEBUG		(2)
# undef DEBUG

#if defined DEBUG 

#define ONE_LINE			     "1"
#define SEC_LINE		       "1   1"
#define THD_LINE		     "1   2    1"
#define	FOR_LINE	       "1   3    3   1"
#define FIV_LINE	     "1   4   6    4   1"
#define SIX_LINE       "1   5  10   10   5   1"
#define SEV_LINE	  "1  6  15   20  15   6   1"
#define EIG_LINE	"1  7  21  35   35   21  7  1"
#define NIN_LINE  "1  8  28  56   70  56   28  8  1"

#endif

int main(int argc, char *argv[]) {
	int i = 0;
	int j = 0;
	int num = 0;
	int **triangle = NULL;
	int temp = 0;

	scanf("%d", &num);
	if (10 <= num) {
		fprintf(stderr, "%s\n", "Input <= 9");
		return -1;
	}
//rintf("%s\n", ONE_LINE);
	triangle = (int **) malloc(sizeof(int *) * num);
	if (NULL == triangle) {
		fprintf(stderr, "%s\n", "Allocate error!");
		return -1;
	}
	for (i = 0; i < num; i++) {
		triangle[i] = (int *) malloc(sizeof(int) * num);
		if (NULL == triangle[i]) {
			fprintf(stderr, "%s\n", "Allocate error!");
			return -1;
		}
	}
	for (i = 0; i < num; i++) {
		triangle[i][0] = triangle[i][i] = 1;
	}
	for (i = 2; i < num; i++) {
		for (j = 1; j < i; j++) {
			triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];
		}
	}
	temp = num;
	for (i = 0; i < num; i++) {
		for (j = temp; j > 0; j--) {
			printf(" ");
		}
		for (j = 0; j <= i; j++) {
			printf("%4d", triangle[i][j]);
		}
		printf("\n");
		temp -= 1;
	}
	/*TODO: free jobs*/
	return 0;
}
